home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / PASCAL / ALLSWAGS.ZIP / SWAGN-R.ZIP / NETWORK.SWG / 0039_Netware 3.11 API Library - File Locking.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-11-29  |  6.4 KB  |  322 lines

  1. {
  2.             ╔══════════════════════════════════════════════════╗
  3.             ║     ┌╦═══╦┐┌╦═══╦┐┌╦═══╦┐┌╦═╗ ╦┐┌╦═══╦┐┌╔═╦═╗┐   ║
  4.             ║     │╠═══╩┘├╬═══╬┤└╩═══╦┐│║ ║ ║│├╬══      ║      ║
  5.             ║     └╩     └╩   ╩┘└╩═══╩┘└╩ ╚═╩┘└╩═══╩┘   ╩      ║
  6.             ║                                                  ║
  7.             ║     NetWare 3.11 API Library for Turbo Pascal    ║
  8.             ║                      by                          ║
  9.             ║                S.Perevoznik                      ║
  10.             ║                     1996                         ║
  11.             ╚══════════════════════════════════════════════════╝
  12. }
  13. Unit NetLock;
  14.  
  15. Interface
  16.  
  17. Uses NetConv;
  18.  
  19.  
  20. Const
  21.  
  22.   cReg  = 0;
  23.   cFull = 1;
  24.   cRead = 3;
  25.  
  26.  
  27.  
  28. Procedure ReleasePhysicalRecordSet;
  29.  
  30.  
  31. Procedure ClearPhysicalRecordSet;
  32.  
  33.  
  34. Function ClearPhysicalRecord (FileName : string;
  35.                               RecordStartOffset,
  36.                               RecordLength  : LongInt) : byte;
  37.  
  38.  
  39. Function ReleasePhysicalRecord (FileName : string;
  40.                                 RecordStartOffset,
  41.                                 RecordLength  : LongInt) : byte;
  42.  
  43.  
  44. Function  LockPhysicalRecordSet(LockDirective : byte;
  45.                                 TimeOutLimit : word ) : byte;
  46.  
  47.  
  48. Function  LogPhysicalRecord(FileName : string;
  49.                             RecordStartOffset,
  50.                             RecordLength  : LongInt;
  51.                             LockDirective : byte;
  52.                             TimeOutLimit  : word) : byte;
  53.  
  54.  
  55.  
  56.  
  57. Function LockFileSet(LockDirective : byte;
  58.                      TimeOutLimit  : word) : byte;
  59.  
  60.  
  61. Procedure ReleaseFileSet;
  62.  
  63.  
  64. Procedure ClearFileSet;
  65.  
  66.  
  67. Function LogFile(FileName : string;
  68.                  LockDirective : byte;
  69.                  TimeOutLimit : word) : byte;
  70.  
  71.  
  72. Function ClearFile(FileName : string) : byte;
  73.  
  74.  
  75. Function ReleaseFile(FileName : string) : byte;
  76.  
  77.  
  78.  
  79.  
  80. Procedure SetLockMode(mode : byte);
  81.  
  82.  
  83. Function  GetLockMode : byte;
  84.  
  85.  
  86. {-----------------------------------------------------------}
  87.  
  88. Implementation
  89.  
  90. Uses DOS;
  91.  
  92.  
  93.  
  94. Procedure ReleasePhysicalRecordSet;
  95.  
  96. var
  97.   r : registers;
  98. Begin
  99.   r.AH := $C3;
  100.   Intr($21,r);
  101. End;
  102.  
  103. Procedure ClearPhysicalRecordSet;
  104.  
  105. var
  106.   r : registers;
  107. Begin
  108.   r.AH := $C4;
  109.   intr($21,r);
  110. End;
  111.  
  112. Function ClearPhysicalRecord (FileName : string;
  113.                               RecordStartOffset,
  114.                               RecordLength  : LongInt) : byte;
  115.  
  116. var
  117.   r : registers;
  118.   FileHandle : word;
  119. Begin
  120.   r.AH := $3D;
  121.   r.DS := SEG(FileName[1]);
  122.   r.DX := OFS(FileName[1]);
  123.   r.AL := 0;
  124.   FileName[length(FileName)+1] := chr(0);
  125.   intr($21,r);
  126.   if (r.FLAGS and FCARRY ) = 0 then
  127.     begin
  128.       FileHandle := r.AX;
  129.       r.AH := $BE;
  130.       r.BX := FileHandle;
  131.       Long2Int(RecordStartOffset,r.DX,r.CX);
  132.       Long2Int(RecordLength,r.DI,r.SI);
  133.       intr($21,r);
  134.       ClearPhysicalRecord := r.AL;
  135.     end
  136.   else
  137.     ClearPhysicalRecord := $80;
  138.  
  139. End;
  140.  
  141. Function ReleasePhysicalRecord (FileName : string;
  142.                                 RecordStartOffset,
  143.                                 RecordLength  : LongInt) : byte;
  144.  
  145. var
  146.   r : registers;
  147.   FileHandle : word;
  148. Begin
  149.   r.AH := $3D;
  150.   r.DS := SEG(FileName[1]);
  151.   r.DX := OFS(FileName[1]);
  152.   r.AL := 0;
  153.   FileName[length(FileName)+1] := chr(0);
  154.   intr($21,r);
  155.   if (r.FLAGS and FCARRY ) = 0 then
  156.     begin
  157.       FileHandle := r.AX;
  158.       r.AH := $BD;
  159.       r.BX := FileHandle;
  160.       Long2Int(RecordStartOffset,r.DX,r.CX);
  161.       Long2Int(RecordLength,r.DI,r.SI);
  162.       intr($21,r);
  163.       ReleasePhysicalRecord := r.AL;
  164.     end
  165.   else
  166.     ReleasePhysicalRecord := $80;
  167.  
  168. End;
  169.  
  170. Function  LockPhysicalRecordSet(LockDirective : byte;
  171.                                 TimeOutLimit : word ) : byte;
  172.  
  173. var
  174.   r : registers;
  175. Begin
  176.   r.AH := $C2;
  177.   r.AL := LockDirective;
  178.   r.BP := TimeOutLimit;
  179.   intr($21,r);
  180.   LockPhysicalRecordSet := r.AL;
  181. End;
  182.  
  183. Function  LogPhysicalRecord(FileName : string;
  184.                             RecordStartOffset,
  185.                             RecordLength  : LongInt;
  186.                             LockDirective : byte;
  187.                             TimeOutLimit  : word) : byte;
  188.  
  189. var
  190.   r : registers;
  191.   FileHandle : word;
  192. Begin
  193.   r.AH := $3D;
  194.   r.DS := SEG(FileName[1]);
  195.   r.DX := OFS(FileName[1]);
  196.   r.AL := 0;
  197.   FileName[length(FileName)+1] := chr(0);
  198.   intr($21,r);
  199.   if (r.FLAGS and FCARRY ) = 0 then
  200.     begin
  201.       FileHandle := r.AX;
  202.       r.AH := $BC;
  203.       r.BX := FileHandle;
  204.       Long2Int(RecordStartOffset,r.DX,r.CX);
  205.       Long2Int(RecordLength,r.DI,r.SI);
  206.  
  207.       r.AL := LockDirective;
  208.       r.BP := TimeOutLimit;
  209.       intr($21,r);
  210.       LogPhysicalRecord := r.AL;
  211.       R.AH := $3E;
  212.       R.BX := FileHandle;
  213.       Intr($21,R);
  214.     end
  215.   else
  216.     LogPhysicalRecord := $80;
  217. End;
  218.  
  219.  
  220.  
  221. Function LockFileSet(LockDirective : byte;
  222.                      TimeOutLimit  : word) : byte;
  223.  
  224. var
  225.   r : registers;
  226. Begin
  227.   r.AH := $CB;
  228.   r.bp := TimeOutLimit;
  229.   r.AL := LockDirective;
  230.   intr($21,r);
  231.   LockFileSet := r.AL;
  232. End;
  233.  
  234. Procedure ReleaseFileSet;
  235.  
  236. var
  237.   r : registers;
  238. Begin
  239.   r.AH := $CD;
  240.   intr($21,r);
  241. End;
  242.  
  243. Procedure ClearFileSet;
  244.  
  245. var
  246.   r : registers;
  247. Begin
  248.   r.AH := $CF;
  249.   intr($21,r);
  250. End;
  251.  
  252. Function LogFile(FileName : string;
  253.                  LockDirective : byte;
  254.                  TimeOutLimit : word) : byte;
  255.  
  256. var
  257.   r : registers;
  258. Begin
  259.   r.AH := $EB;
  260.   r.BP := TimeOutLimit;
  261.   r.AL := LockDirective;
  262.   r.DS := SEG(FileName[1]);
  263.   r.DX := OFS(FileName[1]);
  264.   FileName[length(FileName)+1] := chr(0);
  265.   intr($21,r);
  266.   LogFile := r.AL;
  267.  
  268. End;
  269.  
  270. Function ClearFile(FileName : string) : byte;
  271.  
  272.  
  273. var
  274.   r : registers;
  275. Begin
  276.   r.AH := $ED;
  277.   r.DS := SEG(FileName[1]);
  278.   r.DX := OFS(FileName[1]);
  279.   FileName[length(FileName)+1] := chr(0);
  280.   intr($21,r);
  281.   ClearFile := r.AL;
  282. End;
  283.  
  284. Function ReleaseFile(FileName : string) : byte;
  285.  
  286.  
  287. var
  288.   r : registers;
  289. Begin
  290.   r.AH := $EC;
  291.   r.DS := SEG(FileName[1]);
  292.   r.DX := OFS(FileName[1]);
  293.   FileName[length(FileName)+1] := chr(0);
  294.   intr($21,r);
  295.   ReleaseFile := r.AL;
  296. End;
  297.  
  298.  
  299.  
  300. Procedure SetLockMode(mode : byte);
  301.  
  302. var
  303.   r : registers;
  304. Begin
  305.    r.AH := $C6;
  306.    r.AL := Mode;
  307.    intr($21,r);
  308. End;
  309.  
  310. Function  GetLockMode : byte;
  311.  
  312. var
  313.   r : registers;
  314. Begin
  315.   r.AH := $C6;
  316.   r.AL := $02;
  317.   intr($21,r);
  318.   GetLockMode := r.AL;
  319. End;
  320.  
  321. end.
  322.